package com.zb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zb.entity.ZjWorkSpareReturn;
import com.zb.entity.ZjWorkSpareReturnReceiptSend;
import com.zb.mapper.ZjWorkSpareReturnReceiptSendMapper;
import com.zb.service.ZjWorkSpareReturnReceiptSendService;
import com.zb.service.ZjWorkSpareReturnService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 工单备件旧件退回收发货表 服务实现类
 * </p>
 *
 * @author WEN
 * @since 2023-10-30
 */
@Service
public class ZjWorkSpareReturnReceiptSendServiceImpl extends ServiceImpl<ZjWorkSpareReturnReceiptSendMapper, ZjWorkSpareReturnReceiptSend> implements ZjWorkSpareReturnReceiptSendService {
    @Resource
    private ZjWorkSpareReturnService workSpareReturnService;

    // 根据工单备件ID获取旧件退货收货人信息
    @Override
    public ZjWorkSpareReturnReceiptSend getByWorkSpareId(Long workSpareId) {
        QueryWrapper<ZjWorkSpareReturn> returnQueryWrapper = new QueryWrapper<>();
        returnQueryWrapper.select("id");
        returnQueryWrapper.eq("work_spare_id", workSpareId);
        ZjWorkSpareReturn spareReturn = workSpareReturnService.getOne(returnQueryWrapper);
        return this.getById(spareReturn.getId());
    }
}
